<?php
/**
 * Created by PhpStorm.
 * User: weijer
 * Date: 2018/10/26
 * Time: 21:17
 */

namespace common\validate;

use think\Validate;

class TenantAuthentication extends BaseValidate
{
    //验证规则
    protected $rule = [];

    // Select 验证场景定义
    public function sceneSelect()
    {
        return $this->append('param', 'array')
            ->append('param.filter', 'array')
            ->append('param.page', 'array');
    }

    // Create 验证场景定义
    public function sceneCreate()
    {
        return $this->append('data', 'require')
            ->append('data.tenant_authentication', 'require')
            ->append('data.tenant_authentication.tenant_id', 'require|integer')
            ->append('data.tenant_authentication.status', 'in:submitting,to_be_reviewed')
            ->append('data.tenant_authentication.company_name', 'require|max:255')
            ->append('data.tenant_authentication.unified_social_credit_code', 'require|max:20')
            ->append('data.tenant_authentication.company_registered_address', 'require|max:255')
            ->append('data.tenant_authentication.company_business_scope', 'require')
            ->append('data.tenant_authentication.company_web_site', 'max:255')
            ->append('data.tenant_authentication.company_office_address', 'require|max:255')
            ->append('data.tenant_authentication.company_found_date', 'require|integer|max:11')
            ->append('data.tenant_authentication.company_staff_number', 'integer|max:11')
            ->append('data.tenant_authentication.company_manager_number', 'require|max:40')
            ->append('data.tenant_authentication.company_maker_number', 'require|max:40')
            ->append('data.tenant_authentication.company_profile', 'max:2048')
            ->append('data.tenant_authentication.company_success_stories', 'max:255')
            ->append('data.tenant_authentication.company_demo_links', 'max:255')
            ->append('data.tenant_authentication.company_customer_service', 'array')
            ->append('data.tenant_authentication.operation_period_end', 'require|integer')
            ->append('data.tenant_authentication.bank_of_deposit', 'require|max:128')
            ->append('data.tenant_authentication.bank_subbranch', 'require|max:128')
            ->append('data.tenant_authentication.bank_account', 'require|max:24')
            ->append('data.tenant_authentication.bank_account_owner', 'require|max:128')
            ->append('data.tenant_authentication.legal_person_name', 'require|max:128')
            ->append('data.tenant_authentication.legal_id_number', 'require|max:18')
            ->append('data.tenant_authentication.legal_phone', 'require|max:20')
            ->append('data.tenant_authentication.legal_id_period_end', 'require|integer')
            ->append('data.tenant_authentication.person_in_charge', 'require|max:128')
            ->append('data.tenant_authentication.person_in_charge_phone', 'require|max:20')
            ->append('data.tenant_authentication.person_in_charge_email', 'require|max:128')
            ->append('data.tenant_authentication.office_hardware', 'max:20')
            ->append('data.tenant_authentication.secrecy_level', 'array')
            ->append('data.media_business_license', 'require')
            ->append('data.media_front_of_legal_id', 'require')
            ->append('data.media_reverse_of_legal_id', 'require')
            ->append('data.tenant_authentication.telephone_number', 'require|max:25');
    }

    // Update 验证场景定义
    public function sceneUpdate()
    {
        return $this->append('data.id', 'require')
            ->append('data.status', 'in:submitting,to_be_reviewed')
            ->append('data.tenant_id', 'integer')
            ->append('data.company_name', 'max:255')
            ->append('data.unified_social_credit_code', 'max:20')
            ->append('data.company_registered_address', 'max:255')
            ->append('data.operation_period_end', 'integer')
            ->append('data.bank_of_deposit', 'max:128')
            ->append('data.bank_subbranch', 'max:128')
            ->append('data.bank_account', 'max:24')
            ->append('data.bank_account_owner', 'max:128')
            ->append('data.legal_person_name', 'max:128')
            ->append('data.legal_id_number', 'max:18')
            ->append('data.legal_phone', 'max:20')
            ->append('data.legal_id_period_end', 'integer')
            ->append('data.company_web_site', 'max:255')
            ->append('data.company_office_address', 'max:255')
            ->append('data.person_in_charge', 'max:128')
            ->append('data.person_in_charge_phone', 'max:20')
            ->append('data.person_in_charge_email', 'max:128')
            ->append('data.company_found_date', 'integer|max:11')
            ->append('data.company_staff_number', 'integer|max:11')
            ->append('data.company_manager_number', 'integer|max:11')
            ->append('data.company_maker_number', 'integer|max:11')
            ->append('data.company_profile', 'max:2048')
            ->append('data.company_success_stories', 'max:255')
            ->append('data.company_demo_links', 'max:255')
            ->append('data.office_hardware', 'max:20')
            ->append('data.secrecy_level', 'max:20')
            ->append('data.telephone_number', 'max:25');
    }

    // Delete 验证场景定义
    public function sceneDelete()
    {
        return $this->append('param.filter', 'require');
    }

    // Review 验证场景定义
    public function sceneReview()
    {
        return $this->append("data", "require|array")
            ->append("data.id", "require|integer")
            ->append("data.status", "require|in:active,invalid")
            ->append("data.reasons_for_failure", "requireIf:data.status,invalid")
            ->append("data.level_data", "requireIf:data.status,active");
    }

    // LevelData 验证场景定义
    public function sceneLevelData()
    {
        return $this->append("step_category_id", "require|integer")
            ->append("step_category_name", "require|max:128")
            ->append("step_category_code", "require|max:128")
            ->append("level", "require|max:20");
    }

    // GetSupplierDetails 验证场景定义
    public function sceneGetSupplierDetails()
    {
        return $this->append("param.filter.supplier_id", "require|integer");
    }

    // ChangeTenantStepCategoryLevel 验证场景定义
    public function sceneChangeTenantStepCategoryLevel()
    {
        return $this->append('data', "require|array")
            ->append("data.id", "require|integer")
            ->append('data.level_data', 'array')
            ->append('data.service_category', 'array');
    }

    // FindTenantAuthentication 验证场景定义
    public function sceneFindTenantAuthentication()
    {
        return $this->append('param', 'require')
            ->append('param.filter', 'require');
    }

    // 营业执照提交
    public function sceneBusinessLicenseSubmit()
    {
        return $this->append("data", "require")
            ->append("data.tenant_id", "require|integer")
            ->append("data.company_name", "require|min:3|max:255")
            ->append("data.unified_social_credit_code", "require|max:20")
            ->append("data.person_in_charge", "require|max:128")
            ->append("data.person_in_charge_phone", "require|regex:mobile")
            ->append("data.media_business_license", "require|array")
            ->append("data.company_manager_number", "require|max:40")
            ->append("data.company_maker_number", "require|max:40")
            ->append("data.service_category", "require|array")
            ->append("data.bank_of_deposit", "require|max:128")
            ->append("data.bank_subbranch", "require|max:128")
            ->append("data.bank_account", "require|max:24")
            ->append("data.bank_account_owner", "require|max:128");
    }

    // 法人证件照提交
    public function sceneLegalPersonSubmit()
    {
        return $this->append("data", "require")
            ->append("data.media_front_of_legal_id", "require|array")
            ->append("data.media_reverse_of_legal_id", "require|array")
            ->append("data.legal_person_name", "require|max:128")
            ->append("data.legal_id_number", "require|regex:idCard");
    }

    // 提交审核
    public function sceneSubmitAudit()
    {
        return $this->append("data", "require")
            ->append("data.id", "require|integer");
    }
}
